package UILayer;
import java.util.Scanner;
import java.util.InputMismatchException;

/**
 * This class is used to test the input from the user. It's testing the input when the program wants
 * to recieve and int and if the user enters som letters, this class will handle that.
 * 
 * @author Group1
 * @version 2011-06-05
 */
public class UIInput
{
    public UIInput()
    {
        
    }
    
    public static int inputInt()
    {
        Scanner reader = new Scanner(System.in);
        boolean ok = false;
        int id = 0;
        while(!ok)
        {
            try
            {
                id = reader.nextInt();
                ok = true;
            }
            catch(InputMismatchException ie)
            {
                System.out.println("Only numbers");
                String vent = reader.nextLine();
            }
            catch(Exception e)
            {
                System.out.println("You have to write a number - try again");
                String vent = reader.nextLine();                
            }
        }
        return id;
    }
}